
Partial Class Modules_Questionnaires_Management_QuestionnaireManager
    Inherits System.Web.UI.Page

    Protected Function IsAllowedToDelete() As Boolean
        If User.IsInRole("QuestionnaireAdmins") Then
            Return True
        End If
        Return False
    End Function

    Protected Sub lbutNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbutNew.Click
        Session("questionnaire_questionnaireId") = 0
        Response.Redirect("Questionnaire.aspx")
    End Sub

    Protected Sub gvQuestionnaires_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvQuestionnaires.RowCommand
        'Response.Write("CommandName : " & e.CommandName & "<br/>")
        'Response.Write("CommandArgument : " & e.CommandArgument & "<br/>")
        'Response.Write("CommandSource : " & e.CommandSource.ToString & "<br/>")
        Select Case e.CommandName
            Case "cmdDetail"
                SetQuestionIdSession(Convert.ToInt32(e.CommandArgument))
                Response.Redirect("Questionnaire.aspx")
            Case "cmdEdit"
                SetQuestionIdSession(Convert.ToInt32(e.CommandArgument))
                Response.Redirect("Questionnaire.aspx?Mode=edit")
            Case "cmdPerm"
                SetQuestionIdSession(Convert.ToInt32(e.CommandArgument))
                Response.Redirect("QuestionnairePerm.aspx")
        End Select
    End Sub

    Private Sub SetQuestionIdSession(ByVal rowIndex As Integer)
        Dim row As GridViewRow = gvQuestionnaires.Rows(rowIndex)
        Session("questionnaire_questionnaireId") = _
        CType(row.Cells(4).FindControl("hfID"), HiddenField).Value
        'Response.Write("questionnaire_questionnaireId = " & Session("questionnaire_questionnaireId"))
    End Sub

    Protected Sub iButQuestion_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles iButQuestion.Click
        Response.Redirect("QuestionManager.aspx")
    End Sub

    Protected Sub iButInstrument_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles iButInstrument.Click
        Response.Redirect("InstrumentManager.aspx")
    End Sub
End Class
